import axios from 'axios';
import _ from 'lodash';
let LocationHostName = window.location.hostname;
if (LocationHostName === 'localhost' || LocationHostName === '127.0.0.1') {
    LocationHostName = '/';
} else {
    LocationHostName = window.location.origin + '/index.php?s=';
}
let API = {
    ASSET_SERVER_URL: LocationHostName,
    LOGIN_IMG: '/api/common/index/uploadImg', //图片上传 
    LOGIN_VIDEO: '/api/common/index/uploadVideoFile', //视频上传 
    LOGIN_WX_IMG: '/api/common/Jscwxapi/uploadImg', //微信图片上传 
    GET_WX_CODE: '/api/wechat/Jscwxapi/getWxCode',//获取公众号code
    GET_WX_USERINFO: '/api/wechat/Jscwxapi/getUserInfo',//公众号授权
    GET_SIGN_PACKAGE: '/api/wechat/Jscwxapi/getSignPackage',//公众号网页授权登录
    WX_NEWPAY: '/api/wechat/Jscwxapi/newpay',//微信支付
    GET_CURRICULUM_ZS: '/api/wechat/Jscwxapi/newGivePay',//赞赏支付
    GET_APP_USERINFO: '/api/wechat/Member/getUserInfo',//获取用户信息
    GET_SETUSERROLE: '/api/wechat/Member/setUserRole',//获取用户信息
    SET_USERINFO_MOBILE: '/api/wechat/Member/setUserMobile',//获取用户信息
    GET_HOME_INDEX: '/api/wechat/Home/index',//首页数据
    GET_CURRICULUM_DETAIL: '/api/wechat/Home/curriculumDetail',//课程详情
    GET_CURRICULUM_LIST: '/api/wechat/Home/curriculumList',//课程列表
    GET_CURRICULUM_DETECTION: '/api/wechat/Curriculum/isPlayOk',//判断需要走购买还是进入播放
    GET_CURRICULUM_PLAY_DETAIL: '/api/wechat/Curriculum/curriculumPlayDetail',//课程可播放详情
    GET_CURRICULUM_NOTE: '/api/wechat/Curriculum/curriculumNote',//学员笔记
    GET_CURRICULUM_LIKESLIST: '/api/wechat/Curriculum/likesList',//打赏列表
    GET_CURRICULUM_ADDNOTE: '/api/wechat/Curriculum/curriculumAddNote',//添加笔记
    GET_MEMBER_ORDER: '/api/wechat/Member/getMyOrder',//已购课程
    GET_MEMBER_STUDYLIST: '/api/wechat/Member/studyList',//研习次数
    GET_MEMBER_STUDYTOTAL: '/api/wechat/Member/studyTotal',//研习统计数据
    GET_MEMBER_WORKLIST: '/api/wechat/Member/workList',//作业列表
    GET_MEMBER_WORKTOTAL: '/api/wechat/Member/workTotal',//作业总数
    GET_MEMBER_WORKDETAIL: '/api/wechat/Member/workDetail',//作业详情
    GET_MEMBER_WORKWRITEDETAIL: '/api/wechat/Member/workWriteDetail',//作业书写详情
    SET_MEMBER_SUBMITWORKDETAIL: '/api/wechat/Member/submitWorkDetail',//作业提交
    SET_MEMBER_SETMEMBERNAME: '/api/wechat/Member/setMemberName',//个人信息提交
    SET_PEROFFICE_INDEX: '/api/wechat/Peroffice/index',//个人办公首页
    SET_PEROFFICE_NOTELIST: '/api/wechat/Peroffice/noteList',//个人办公公告列表
    SET_PEROFFICE_NOTEDETAIL: '/api/wechat/Peroffice/noteDetail',//个人办公公告详情
    SET_PEROFFICE_BINDPARENT: '/api/wechat/Peroffice/bindParent',//个人办公公告详情
    SET_PEROFFICE_IMAGESTEXT: '/api/wechat/Peroffice/imagesText',//个人办公图文教程
    SET_PEROFFICE_IMAGESTEXTDETAIL: '/api/wechat/Peroffice/imagesTextDetail',//个人办公图文教程
    SET_PEROFFICE_ADVISERTEACHERLIST: '/api/wechat/Peroffice/adviserTeacherList',//顾问老师使用教程
    SET_PEROFFICE_ADVISERTEACHERDETAIL: '/api/wechat/Peroffice/adviserTeacherDetail',//顾问老师使用详情
    GET_PEROFFICE_GETMEMEMBERTOTAL: '/api/wechat/Peroffice/getMeMemberTotal',//用户信息统计
    GET_PEROFFICE_GETMEMEMBERLIST: '/api/wechat/Peroffice/getMeMemberList',//用户信息查询
    SET_PEROFFICE_SALETOTALCLASS: '/api/wechat/Peroffice/saleTotalClass',//销售总报课程列表
    SET_PEROFFICE_SALETOTALSEARCH: '/api/wechat/Peroffice/saleTotalSearch',//销售总报课程列表查询
    SET_PEROFFICE_PERFORMANCE: '/api/wechat/Peroffice/performance',//业绩统计列表查询
    SET_PEROFFICE_PERFORMANCESEARCH: '/api/wechat/Peroffice/performanceSearch',//业绩统计查询
    GET_PEROFFICE_SALEBRANCH: '/api/wechat/Peroffice/saleBranch',//业绩统计查询
    GET_PEROFFICE_BINDUSERS: '/api/wechat/Peroffice/bindUsers',//绑定数量
    GET_PEROFFICE_WORKMYORDER: '/api/wechat/Peroffice/workMyOrder',//订单
    GET_PEROFFICE_WORKMYSIGNUP: '/api/wechat/Peroffice/workMySignUp',//报名
    GET_PEROFFICE_WORKMYSIGNUPDETAIL: '/api/wechat/Peroffice/workMySignUpDetail',//报名
    SET_PEROFFICE_WORKMYSIGNUPSUBMIT: '/api/wechat/Peroffice/workMySignUpSubmit',//报名
    SET_USERINFO: '/api/wechat/Member/setMemberName',//更新用户信息
    GET_WX_CONTENT:'/api/wechat/Apiwechat/getWxContent',

    GET_ACTIVE_DETAIL: '/api/wechat/home/activeDetail',//获取赛事详情
    USER_SIGNUP: '/api/wechat/home/setUserSingUp',//用户报名
    USER_WORKS_LIST: '/api/wechat/home/userWorksList',//作品列表
    USER_WORKS_DEL: '/api/wechat/home/userWorksDel',//作品列表删除
    UPLOAD_USER_WORKS: '/api/wechat/home/submitUserUpload',//作品图片上传
    UPLOAD_USER_VIDEO_WORKS: '/api/wechat/home/submitUserVideoUpload',//作品图片上传
    UPLOAD_USER_IMGS: '/api/wechat/home/uploadImg',//身份信息删除
    SUBMIT_USER_WORKS: '/api/wechat/home/submitUserWorks',//作品提交
    USER_SINGUP_LIST: '/api/wechat/home/userSingupList',//报名列表
    USER_RANK_LIST: '/api/wechat/home/userRankList',//排行版
    SCORING_LIST: '/api/wechat/home/scoringList',//评委评审列表
    SET_SCORING: '/api/wechat/home/scoring',//评委打分
    USER_SIGNUP_DEL: '/api/wechat/home/delSingUp',//删除打分
    IS_PLY_WROKS: '/api/wechat/home/isPayWorks',//是否已打分
    USER_CERTIFICATE_LIST: '/api/wechat/home/certificate',//证书列表
    USER_RANK_CERTIFICATE: '/api/wechat/home/certificateDown',//证书下载
    RECOGNITION_LIST: '/api/wechat/Member/listRecognition',//身份信息列表
    RECOGNITION_DEL: '/api/wechat/Member/delRecognition',//身份信息删除
    RECOGNITION_EDIT: '/api/wechat/Member/setRecognition',//身份信息删除
    RECOGNITION_DETAIL: '/api/wechat/Member/detailRecognition',//身份信息删除
};

export function getConfig() {
    return new Promise(resolve => {
        axios.get(`${window.location.origin}${(process.env.NODE_ENV === 'development' ? '' : '/weChatApp')}/webconfig.json?v=${new Date().getTime()}`).then((response) => {
            if (response.data && _.isPlainObject(response.data)) {
                resolve(Object.assign(API, response.data));
            } else {
                resolve(API);
            }
        }, () => {
            resolve(API);
        });
    });
}
export default API;

